package com.ruoyi.app.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.KeyValue;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.utils.DictUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 描述 App数据字典Controller
 * 作者 ZhangPing
 * 创建时间 2023/10/9 9:52
 */
@RestController
@RequestMapping("/app/dataDict")
@Slf4j
public class AppDataDictController extends BaseController {

    @ApiOperation("监管类型字典")
    @GetMapping("/getDataDict/22")
    public AjaxResult objectTypeDict() {
        List<SysDictData> dataList = DictUtils.getDictCache("objType");
        return success(dataList.stream().map(i -> new KeyValue(i.getDictValue(), i.getDictLabel())).collect(Collectors.toList()));
    }

}
